package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * C端-用户表
 */
@Mapper
public interface UserMapper {
    /**
     * 根据openid查询用户
     * @param openid
     * @return
     */
    @Select("select * from sky_take_out.user where openid = #{openid}")
    User getUserByOpenid(String openid);

    /**
     * 新增用户
     * @param user
     */
    @Insert("insert into sky_take_out.user(openid, name, phone, sex, id_number, avatar, create_time) VALUES " +
            "(#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    void insertUser(User user);

    /**
     * 根据用户id查用户
     * @param
     * @return
     */
    @Select("select * from sky_take_out.user where id = #{id}")
    User getById(Long id);


    /**
     * 用户统计
     * @param map
     * @return
     */
    Integer countUserByMap(Map<String, Object> map);
}
